﻿using System;
using System.ComponentModel;
using System.IO;
using System.Runtime.Serialization;

namespace HalconDotNet
{
	/// <summary>Represents an instance of a structured light model.</summary>
	// Token: 0x02000066 RID: 102
	[Serializable]
	public class HStructuredLightModel : HHandle, ISerializable, ICloneable
	{
		// Token: 0x06001851 RID: 6225 RVA: 0x0000883B File Offset: 0x00006A3B
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HStructuredLightModel() : base(HHandleBase.UNDEF)
		{
		}

		// Token: 0x06001852 RID: 6226 RVA: 0x0009BDD0 File Offset: 0x00099FD0
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HStructuredLightModel(IntPtr handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x06001853 RID: 6227 RVA: 0x0009BDDF File Offset: 0x00099FDF
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HStructuredLightModel(HHandle handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x06001854 RID: 6228 RVA: 0x0009BDEE File Offset: 0x00099FEE
		private void AssertSemType()
		{
			base.AssertSemType("structured_light_model");
		}

		// Token: 0x06001855 RID: 6229 RVA: 0x0009BDFB File Offset: 0x00099FFB
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HStructuredLightModel obj)
		{
			obj = new HStructuredLightModel(HHandleBase.UNDEF);
			return obj.Load(proc, parIndex, err);
		}

		// Token: 0x06001856 RID: 6230 RVA: 0x0009BE14 File Offset: 0x0009A014
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HStructuredLightModel[] obj)
		{
			HTuple htuple;
			err = HTuple.LoadNew(proc, parIndex, err, out htuple);
			obj = new HStructuredLightModel[htuple.Length];
			for (int i = 0; i < htuple.Length; i++)
			{
				obj[i] = new HStructuredLightModel(HalconAPI.IsLegacyHandleMode() ? htuple[i].IP : htuple[i].H);
			}
			htuple.Dispose();
			return err;
		}

		/// <summary>
		///   Create a structured light model.
		///   Modified instance represents: Handle for using and accessing the structured light model.
		/// </summary>
		/// <param name="modelType">The type of the created structured light model. Default: "deflectometry"</param>
		// Token: 0x06001857 RID: 6231 RVA: 0x0009BE84 File Offset: 0x0009A084
		public HStructuredLightModel(string modelType)
		{
			IntPtr proc = HalconAPI.PreCall(2107);
			HalconAPI.StoreS(proc, 0, modelType);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		// Token: 0x06001858 RID: 6232 RVA: 0x0009BED0 File Offset: 0x0009A0D0
		void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
		{
			HSerializedItem hserializedItem = this.SerializeStructuredLightModel();
			byte[] value = hserializedItem;
			hserializedItem.Dispose();
			info.AddValue("data", value, typeof(byte[]));
		}

		// Token: 0x06001859 RID: 6233 RVA: 0x0009BF08 File Offset: 0x0009A108
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HStructuredLightModel(SerializationInfo info, StreamingContext context)
		{
			HSerializedItem hserializedItem = new HSerializedItem((byte[])info.GetValue("data", typeof(byte[])));
			this.DeserializeStructuredLightModel(hserializedItem);
			hserializedItem.Dispose();
		}

		/// <summary>Serialize object to binary stream in HALCON format</summary>
		// Token: 0x0600185A RID: 6234 RVA: 0x0009BF48 File Offset: 0x0009A148
		public new void Serialize(Stream stream)
		{
			HSerializedItem hserializedItem = this.SerializeStructuredLightModel();
			hserializedItem.Serialize(stream);
			hserializedItem.Dispose();
		}

		/// <summary>Deserialize object from binary stream in HALCON format</summary>
		// Token: 0x0600185B RID: 6235 RVA: 0x0009BF5C File Offset: 0x0009A15C
		public new static HStructuredLightModel Deserialize(Stream stream)
		{
			HStructuredLightModel hstructuredLightModel = new HStructuredLightModel();
			HSerializedItem hserializedItem = HSerializedItem.Deserialize(stream);
			hstructuredLightModel.DeserializeStructuredLightModel(hserializedItem);
			hserializedItem.Dispose();
			return hstructuredLightModel;
		}

		// Token: 0x0600185C RID: 6236 RVA: 0x0009BF82 File Offset: 0x0009A182
		object ICloneable.Clone()
		{
			return this.Clone();
		}

		// Token: 0x0600185D RID: 6237 RVA: 0x0009BF8C File Offset: 0x0009A18C
		public new HStructuredLightModel Clone()
		{
			HSerializedItem hserializedItem = this.SerializeStructuredLightModel();
			HStructuredLightModel hstructuredLightModel = new HStructuredLightModel();
			hstructuredLightModel.DeserializeStructuredLightModel(hserializedItem);
			hserializedItem.Dispose();
			return hstructuredLightModel;
		}

		/// <summary>Clear a structured light model and free the allocated memory.</summary>
		/// <param name="structuredLightModel">Handle of the structured light model.</param>
		// Token: 0x0600185E RID: 6238 RVA: 0x0009BFB4 File Offset: 0x0009A1B4
		public static void ClearStructuredLightModel(HStructuredLightModel[] structuredLightModel)
		{
			HTuple htuple = HHandleBase.ConcatArray(structuredLightModel);
			IntPtr proc = HalconAPI.PreCall(2106);
			HalconAPI.Store(proc, 0, htuple);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(htuple);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(structuredLightModel);
		}

		/// <summary>
		///   Clear a structured light model and free the allocated memory.
		///   Instance represents: Handle of the structured light model.
		/// </summary>
		// Token: 0x0600185F RID: 6239 RVA: 0x0009BFF8 File Offset: 0x0009A1F8
		public void ClearStructuredLightModel()
		{
			IntPtr proc = HalconAPI.PreCall(2106);
			base.Store(proc, 0);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a structured light model.
		///   Modified instance represents: Handle for using and accessing the structured light model.
		/// </summary>
		/// <param name="modelType">The type of the created structured light model. Default: "deflectometry"</param>
		// Token: 0x06001860 RID: 6240 RVA: 0x0009C02C File Offset: 0x0009A22C
		public void CreateStructuredLightModel(string modelType)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(2107);
			HalconAPI.StoreS(proc, 0, modelType);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Decode the camera images acquired with a structured light setup.
		///   Instance represents: Handle of the structured light model.
		/// </summary>
		/// <param name="cameraImages">Acquired camera images.</param>
		// Token: 0x06001861 RID: 6241 RVA: 0x0009C078 File Offset: 0x0009A278
		public void DecodeStructuredLightPattern(HImage cameraImages)
		{
			IntPtr proc = HalconAPI.PreCall(2108);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, cameraImages);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
			GC.KeepAlive(cameraImages);
		}

		/// <summary>
		///   Deserialize a structured light model.
		///   Modified instance represents: Handle of the structured light model.
		/// </summary>
		/// <param name="serializedItemHandle">Handle of the serialized item.</param>
		// Token: 0x06001862 RID: 6242 RVA: 0x0009C0BC File Offset: 0x0009A2BC
		public void DeserializeStructuredLightModel(HSerializedItem serializedItemHandle)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(2110);
			HalconAPI.Store(proc, 0, serializedItemHandle);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(serializedItemHandle);
		}

		/// <summary>
		///   Generate the pattern images to be displayed in a structured light setup.
		///   Instance represents: Handle of the structured light model.
		/// </summary>
		/// <returns>Generated pattern images.</returns>
		// Token: 0x06001863 RID: 6243 RVA: 0x0009C110 File Offset: 0x0009A310
		public HImage GenStructuredLightPattern()
		{
			IntPtr proc = HalconAPI.PreCall(2113);
			base.Store(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HImage result;
			num = HImage.LoadNew(proc, 1, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Query parameters of a structured light model.
		///   Instance represents: Handle of the structured light model.
		/// </summary>
		/// <param name="genParamName">Name of the queried model parameter. Default: "min_stripe_width"</param>
		/// <returns>Value of the queried model parameter.</returns>
		// Token: 0x06001864 RID: 6244 RVA: 0x0009C158 File Offset: 0x0009A358
		public HTuple GetStructuredLightModelParam(HTuple genParamName)
		{
			IntPtr proc = HalconAPI.PreCall(2117);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, genParamName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Query parameters of a structured light model.
		///   Instance represents: Handle of the structured light model.
		/// </summary>
		/// <param name="genParamName">Name of the queried model parameter. Default: "min_stripe_width"</param>
		/// <returns>Value of the queried model parameter.</returns>
		// Token: 0x06001865 RID: 6245 RVA: 0x0009C1B0 File Offset: 0x0009A3B0
		public HTuple GetStructuredLightModelParam(string genParamName)
		{
			IntPtr proc = HalconAPI.PreCall(2117);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Get (intermediate) iconic results of a structured light model.
		///   Instance represents: Handle of the structured light model.
		/// </summary>
		/// <param name="objectName">Name of the iconic result to be returned. Default: "correspondence_image"</param>
		/// <returns>Iconic result.</returns>
		// Token: 0x06001866 RID: 6246 RVA: 0x0009C200 File Offset: 0x0009A400
		public HObject GetStructuredLightObject(HTuple objectName)
		{
			IntPtr proc = HalconAPI.PreCall(2118);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, objectName);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(objectName);
			HObject result;
			num = HObject.LoadNew(proc, 1, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Get (intermediate) iconic results of a structured light model.
		///   Instance represents: Handle of the structured light model.
		/// </summary>
		/// <param name="objectName">Name of the iconic result to be returned. Default: "correspondence_image"</param>
		/// <returns>Iconic result.</returns>
		// Token: 0x06001867 RID: 6247 RVA: 0x0009C258 File Offset: 0x0009A458
		public HObject GetStructuredLightObject(string objectName)
		{
			IntPtr proc = HalconAPI.PreCall(2118);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, objectName);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HObject result;
			num = HObject.LoadNew(proc, 1, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Read a structured light model from a file.
		///   Modified instance represents: Handle of the structured light model.
		/// </summary>
		/// <param name="fileName">File name.</param>
		// Token: 0x06001868 RID: 6248 RVA: 0x0009C2A8 File Offset: 0x0009A4A8
		public void ReadStructuredLightModel(string fileName)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(2123);
			HalconAPI.StoreS(proc, 0, fileName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Serialize a structured light model.
		///   Instance represents: Handle of the structured light model.
		/// </summary>
		/// <returns>Handle of the serialized item.</returns>
		// Token: 0x06001869 RID: 6249 RVA: 0x0009C2F4 File Offset: 0x0009A4F4
		public HSerializedItem SerializeStructuredLightModel()
		{
			IntPtr proc = HalconAPI.PreCall(2127);
			base.Store(proc, 0);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HSerializedItem result;
			num = HSerializedItem.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Set parameters of a structured light model.
		///   Instance represents: Handle of the structured light model.
		/// </summary>
		/// <param name="genParamName">Name of the model parameter to be adjusted. Default: "min_stripe_width"</param>
		/// <param name="genParamValue">New value of the model parameter. Default: 32</param>
		// Token: 0x0600186A RID: 6250 RVA: 0x0009C33C File Offset: 0x0009A53C
		public void SetStructuredLightModelParam(HTuple genParamName, HTuple genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(2130);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, genParamName);
			HalconAPI.Store(proc, 2, genParamValue);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Set parameters of a structured light model.
		///   Instance represents: Handle of the structured light model.
		/// </summary>
		/// <param name="genParamName">Name of the model parameter to be adjusted. Default: "min_stripe_width"</param>
		/// <param name="genParamValue">New value of the model parameter. Default: 32</param>
		// Token: 0x0600186B RID: 6251 RVA: 0x0009C38C File Offset: 0x0009A58C
		public void SetStructuredLightModelParam(string genParamName, int genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(2130);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.StoreI(proc, 2, genParamValue);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Write a structured light model to a file.
		///   Instance represents: Handle of the structured light model.
		/// </summary>
		/// <param name="fileName">File name.</param>
		// Token: 0x0600186C RID: 6252 RVA: 0x0009C3D0 File Offset: 0x0009A5D0
		public void WriteStructuredLightModel(string fileName)
		{
			IntPtr proc = HalconAPI.PreCall(2133);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, fileName);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}
	}
}
